/**
 * 
 */
package com.kandinfo.survey.common.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.kandinfo.base.common.constant.ResultCode;
import com.kandinfo.base.common.dto.ResultDto;
import com.kandinfo.base.common.dto.ResultDtoFactory;
import com.kandinfo.survey.common.service.QuestionnaireSerivce;

/**
 * 问卷定义Controller common
 * 
 * @author tangqh
 * @editor Patrick-chenzp
 */
@Controller
@RequestMapping(value = "/questionnaire")
public class QuestionnaireController {

    @Autowired
    QuestionnaireSerivce questionaireService;

    /**
     * 问卷管理入口
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public String index(Model model) {
        return "views/questionnaire/questionnaire-list";
    }

    /**
     * 问卷详细信息入口
     */
    @RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
    public String detail(Model model, @PathVariable Long id) {
        return "views/questionnaire/questionnaire-detail";
    }

    /**
     * 通过ID或ID List获取数据
     */
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public ResultDto get(Model model, @RequestParam("id") Long id, @RequestParam("idList[]") List<Long> idList) {
        return ResultDtoFactory.createResult(ResultCode.SUCCESS, "查询成功", questionaireService.get(id, idList));
    }
}
